﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ETC.DLEDLightingSystemPlus.Models
{
    /// <summary>
    /// 测试工位
    /// </summary>
    public class StationInfo : Bandit.UI.MVVM.NotifyObject
    {
        private bool _IsSelected;
        /// <summary>
        /// 标识是否选中
        /// </summary>
        [System.Xml.Serialization.XmlIgnore]
        public bool IsSelected
        {
            get { return _IsSelected; }
            set
            {
                _IsSelected = value;
                OnPropertyChanged("IsSelected");
            }
        }

        [System.Xml.Serialization.XmlAttribute()]
        public Guid ID { get; set; }

        private int _Index;
        /// <summary>
        /// Index
        /// </summary>
        [System.Xml.Serialization.XmlAttribute()]
        public int Index
        {
            get { return _Index; }
            set
            {
                _Index = value;
                OnPropertyChanged("Index");
                OnPropertyChanged("Number");
            }
        }

        [System.Xml.Serialization.XmlIgnore]
        public int Number
        {
            get
            {
                return this.Index + 1;
            }
        }

        private string _Name;
        /// <summary>
        /// COM
        /// </summary>
        [System.Xml.Serialization.XmlAttribute()]
        public string Name
        {
            get { return _Name; }
            set
            {
                _Name = value;
                OnPropertyChanged("Name");
                OnPropertyChanged("DisplayName");
            }
        }

        private string _ComPort;
        /// <summary>
        /// COM
        /// </summary>
        [System.Xml.Serialization.XmlAttribute()]
        public string ComPort
        {
            get { return _ComPort; }
            set
            {
                _ComPort = value;
                OnPropertyChanged("ComPort");
            }
        }


        public string DisPlayName
        {
            get
            {
                return string.Format("[{0}-({1})]{2}{3}", Name,ComPort, string.IsNullOrWhiteSpace(TestConfigFile) ? "" : " - ", System.IO.Path.GetFileName(TestConfigFile));
            }
        }
       

        private string _TestConfigFile;
        /// <summary>
        /// 测试配置文件
        /// </summary>
        [System.Xml.Serialization.XmlAttribute()]
        public string TestConfigFile
        {
            get { return _TestConfigFile; }
            set
            {
                _TestConfigFile = value;
                OnPropertyChanged("TestConfigFile");
                OnPropertyChanged("Name");
                OnPropertyChanged("DisplayName");
            }
        }
        public bool ShouldSerializeTestConfigFile()
        {
            return !string.IsNullOrWhiteSpace(_TestConfigFile);
        }

        public StationInfo() { }

        public StationInfo(string Name,string ComPort,int Index)
        {

            this.ID = Guid.NewGuid();
            this.ComPort = ComPort;
            this.Name = Name;
            this.Index = Index;
            
        }
    }
}
